<h3><?php echo $title;  $lang = "vi"; ?></h3>
<script type="text/javascript">
    var newwindown;
    function showWindow(order_id)
    {
    	var url = "/admin/order/printer/"+order_id;
        newwindown = window.open(url,"newwindown","menubar=yes,width=520px,height=300px,scrollbars=yes,resizable=no");
		
    }
 /*    function aa()
{
	var url = document.location.href;
	if(url.lastIndexOf("status=0") != -1)
	 document.location.href = url;
}
setInterval("aa()",60000);
   */ </script>

<?php 
echo form_open('admin/order/sort_date');


?>


<div > <select name="month" >
<?php 
	for($i =1 ; $i<=12 ;$i++)
	{
		if($i <10)
		echo "<option value='0".$i."'>0".$i." </option>";
		else
		echo "<option value='".$i."'>".$i." </option>";
		
	}
?> 

</select>Tháng
<select name="year">
<?php 
	for($i =2011 ; $i<=2021 ;$i++)
	{
		echo "<option value='".$i."'>".$i." </option>";
	}
?> 



</select>
<input type="submit" value="Xem" name="sort"  />
</div>
<?php 
echo form_close();
echo form_open('admin/order/request'); ?>

<div class="control1">

<?php

	//add button

// echo link_image('admin/product/create', 'images/admin/button_add.png');

  

  //delete button
/*
if(!empty($result) & $result[0]["deleted"] ==0)
  		$data = array('name' => 'delete', 'value' => '',"style"=>"margin-right:75px;", 'id' => 'delete');
	else
		$data = array('name' => 'undelete', 'value' => 'Undedele',"style"=>"margin-right:75px;", 'id' => 'undelete');

  echo form_submit($data);
*/
 

  //show field

  $data = array('name' => 'show', 'value' => '', 'id' => 'show',"style"=>"margin-left:600px;");	

  echo form_submit($data);
//$_SESSION['row_number']
  $data = array('name' => 'row_number', 'value' => $_SESSION['row_number'], 'id' => 'show_number');	

  echo form_input($data);

?>

</div><!--control1 end-->
<table class="default" style="">

<?php

	if ( is_array($result) )

	{

		//title

		echo '<tr >';

		echo '<th width="50">&nbsp;</th>';

//    echo '<th width="70">Active</th>';
	echo '<th width="20">&nbsp;</th>';
    echo '<th width="50">Mã Đơn</th>';
//		  echo '<th width="100">'.$this->lang->line('code_product').'-'.$this->lang->line('product_name').'</th>';
		echo '<th width="90">Tên khách hàng</th>';
			echo '<th width="100">'."Ngày đặt hàng".'</th>';
				echo '<th width="100">'."Ngày yêu cầu giao".'</th>';
					echo '<th width="90">Người giao</th>';
				echo '<th width="70">Tổng Tiền</th>';
				echo '<th width="110">Tình trạng</th>';
	
		//echo '<th width="50">'.$this->lang->line('new_product').'</th>';
		//echo '<th width="100">Info</th>';

		echo '</tr>';

		

		//print

		foreach ($result as $row)

		{

			echo '<tr>';



			//action

			echo '<td>';

			echo form_checkbox('select_id[]', $row['order_id']);

			echo '&nbsp;';

			echo anchor('admin/order/update/'.$row['order_id'], 'Edit');

			echo '</td>';
// printer
			echo '<td>';

			//echo form_checkbox('select_id[]', $row['order_id']);

			echo '<a href="#"  onClick="showWindow('.$row["order_id"].')" >In</a>&nbsp;';

			//echo anchor('admin/order/update/'.$row['order_id'], 'Edit');

			echo '</td>';

			
//print_r($result);
   


///$name = unserialize($row['prod_name']);
      //Code

			echo '<td>';

      echo "#".$row['order_id'];

		//	echo '</td>';
//Mã SP
if(isset($row["name"]))
{
	$cus_name = unserialize($row['name']);
}
else
{
	$c = &get_instance();
	if($row["customer_id"]!= 0)
	{
	
		$c->load->model("Mcustomer");
		$a=	$c->Mcustomer->info_form_id($row["customer_id"]);
		$cus_name = unserialize($a[0]["name"]);
		$cus_name_full = $cus_name["full"];
	}
	else
	{
		$cus_name_full= $row["cus_name"];
		$cus_phone = $row["cus_phone"];

	}
}

echo '<td>';

   //   echo $code[$lang];
	 echo  "".$cus_name_full;
			echo '</td>';

  // Ngày đặt hàng

			echo '<td>';

   echo "<font style='color:red;font-weight:bold' >".$row["order_date"]."</font>";

			echo '</td>';

	
			


      // ngày giao hàng

			echo '<td>';

     echo "<font style='color:red;font-weight:bold' >".$row["delivery_date"]."</font>";

			echo '</td>';

	
      // ngày giao hàng

			echo '<td>';

   echo $row["deliverer"];

			echo '</td>';


      // ngày giao hàng

			echo '<td>';

   echo number_format($row["total"],",");

			echo '</td>';

		echo '<td>';
	if($row['delivered'] == 0 )
		{
			
			if($row['deleted'] == 1 )
			{
				echo "Chưa Giao Hàng - <font color='red'>Đã Xóa</font> ";
			}
			else
				echo "Chưa Giao Hàng";
		}
		else if($row['delivered'] == 1 )
		{
			if($row['deleted'] == 1 )
			{
				echo "Đã Giao Hàng - <font color='red'>Đã Xóa</font> ";
			}
			else
				echo "Đã Giao Hàng";
	
	
			
		}
  

			echo '</td>';

	
			



			echo '</tr>';

		}

	}

	else

	{

		echo 'Data does not exist';

	}

?>

</table><!--end main content-->



<?php

	echo form_close(); //FORM END

	

	//page
	
	echo '<div class="page">'.$page.'</div>';

?>